package com.sniper.springmvc.sitemesh3;

import com.sniper.springmvc.config.Global;
import org.sitemesh.builder.SiteMeshFilterBuilder;
import org.sitemesh.config.ConfigurableSiteMeshFilter;

public class MySiteMeshFilter extends ConfigurableSiteMeshFilter {

    public String getDefaultTemplate() {
        return Global.getConfig("defaultTemplate");
    }

    public String getAdminPath() {
        return Global.getConfig("adminPath");
    }

    private String template = "/WEB-INF/modules/themes/";


    @Override
    protected void applyCustomConfiguration(SiteMeshFilterBuilder builder) {

        builder
                //后台
                .addDecoratorPath(getAdminPath() + "*", template + getDefaultTemplate() + "/admin/main.jsp")
                .addExcludedPath(getAdminPath() + "/login*")
                .addExcludedPath(getAdminPath() + "/admin-print*")
                .addExcludedPath(getAdminPath() + "/file-upload*");

    }
}
